{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="用户昵称|评论内容|热文内容"/>
                        </div>
                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="comment_see" class="layui-input">
                                <option value="" >不限匿名</option>
                                <option value="1">不匿名</option>
                                <option value="2">匿名</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="comment_god" class="layui-input">
                                <option value="" >不限神评</option>
                                <option value="1">不是神评</option>
                                <option value="2">是神评</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('add')}');">-->
                        <!--<i class="fa fa-plus"></i> 添加-->
                        <!--</button>-->
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('unbookAdd')}');" style="margin-left: 5px">-->
                        <!--<i class="fa fa-plus"></i> 添加非图书-->
                        <!--</button>-->

                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                        <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                        <!--&lt;!&ndash;<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>&ndash;&gt;-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-check-circle"></i> 批量上架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-ban"></i> 批量下架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <!--<div class="col-sm-12">-->
                <!--<div class="input-group" >-->
                <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                <!--</button>-->
                <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                <!--<li><a href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-check-circle"></i> 批量导入 </a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-ban"></i> 批量上架</a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-trash-o"></i> 批量下架</a></li>-->
                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchDel"><i class="fa fa-trash-o"></i> 批量删除</a></li>-->
                <!--&lt;!&ndash;<li><a  href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-external-link"></i> 批量导入</a></li>&ndash;&gt;-->
                <!--</ul>-->
                <!--</div>-->
                <!--</div>-->
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <script type="text/html" id="comment_see">
                        {{# if(d.comment_see == 1){ }}
                        非匿名
                        {{# } }}
                        {{# if(d.comment_see == 2){ }}
                        匿名评论
                        {{# } }}
                    </script>
                    <script type="text/html" id="comment_god">
                        {{# if(d.comment_god == 1){ }}
                        不是神评
                        {{# } }}
                        {{# if(d.comment_god == 2){ }}
                        <span style="color: red;">是神评</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        {{# if(d.comment_god == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.comment_id}}','{:url('Dyn/godyes')}','设为神评?')" class="btn btn-primary btn-xs m-r-xs" title="设为神评">设为神评</a>
                        {{# } }}
                        {{# if(d.comment_god == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.comment_id}}','{:url('Dyn/godno')}','取消神评?')" class="btn btn-danger btn-xs m-r-xs" title="取消神评">取消神评</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('回复列表', '{:url('Dyn/commentReply')}?comment_id={{d.comment_id}}')" class="btn btn-primary btn-xs m-r-xs" title="查看回复">查看回复</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.comment_id}}','{:url('Dyn/commentDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("evaluate/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                {type:'numbers', width: 70, title: '序号'}
                , {field: 'user_username', width: 120, title: '评论用户', align: 'center'}
                , {field: 'comment_content', width: '', title: '评论内容', align: 'center'}
                , {field: 'h_content', width: '', title: '所属热文', align: 'center'}
                , {field: 'comment_see', width: '', title: '是否匿名', align: 'center',templet: '#comment_see'}
                , {field: 'comment_god', width: '', title: '是否神评', align: 'center',templet: '#comment_god'}
                , {field: 'comment_yes', width: '', title: '赞数', align: 'center'}
                , {field: 'comment_no', width: '', title: '踩数', align: 'center'}
                , {field: 'comment_num', width: '', title: '回复数', align: 'center'}
                , {field: 'comment_time', width: 160, title: '评论时间', align: 'center'}
                , {fixed: 'right', width:250, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.layui-cricle').viewer();//图片查看器
            }
        });
        //监听单元格编辑
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
            var patrn = /^[0-9]*$/;
            if(!patrn.test(value)){
                layer.msg('排序值只能为数字',{icon:2,time:1500,shade: 0.1},function(){
                    //重载当前页表格
                    $(".layui-laypage-btn").click();
                });
                return false;
            }
            wk.changeSort(data.banner_id,"{:url('sort')}",field,value);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量删除
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('del')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['s_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>